#include "mainwindow.h"
#include "ui_mainwindow.h"

void MainWindow::initPlayer()
{
    // 生成音乐播放器
    player = new QMediaPlayer(this);
    // 加载音乐文件夹
    musicDir = "C:\\Users\\HUAWEI\\Desktop\\QtProject\\MusicPlayer\\MusicList\\";
    loadAppointMusicDir(musicDir);
    // 第一行高亮
    ui->musicList->setCurrentRow(0);
    // 加载音乐路径
    QString musicName = ui->musicList->currentItem()->text();
    QString firstMusicPath = "C:\\Users\\HUAWEI\\Desktop\\QtProject\\MusicPlayer\\MusicList\\" + musicName + ".mp3";
    player->setMedia(QUrl::fromLocalFile(firstMusicPath));
    // 播放模式
    mode = Order_Mode;
}
